//
//  UIButton+SPGraphicButton.m
//  ShopProject
//
//  Created by 颜魏 on 2018/11/28.
//  Copyright © 2018年 KB. All rights reserved.
//

#import "UIButton+SPGraphicButton.h"

@implementation UIButton (SPGraphicButton)

- (void)setButtonContentCenter {
    CGFloat imageHeight = self.imageView.size.height;
    CGFloat titleHeight = self.titleLabel.size.height;
    CGFloat titleWidth = [self.titleLabel.text sizeWithAttributes:@{NSFontAttributeName: self.titleLabel.font}].width;
    CGFloat imageWidth = self.imageView.image.size.width;
    CGFloat space = 5;
    [self setImageEdgeInsets:UIEdgeInsetsMake(-(imageHeight*0.5 + space*0.5), titleWidth*0.5, imageHeight*0.5 + space*0.5, -titleWidth*0.5)];
    [self setTitleEdgeInsets:UIEdgeInsetsMake(titleHeight*0.5 + space*0.5, -imageWidth*0.5, -(titleHeight*0.5 + space*0.5), imageWidth*0.5)];
}


@end
